{template '_header'}

<div class="page-header">
    当前位置：<span class="text-primary">{if !empty($notice['id'])}编辑{else}添加{/if}公告{if !empty($notice['id'])}({$notice['title']}){/if}</span>
</div>

<div class="page-content">
    <div class="page-sub-toolbar">
        <span class=''>
            {ifp 'shop.notice.add'}
                <a class="btn btn-primary btn-sm" href="{php echo webUrl('shop/notice/add')}">添加新公告</a>
            {/if}
        </span>
    </div>
    <form {ife 'shop.notice' $notice}action="" method="post"{/if} class="form-horizontal form-validate" enctype="multipart/form-data" onsubmit='return formcheck()'>
        <input type="hidden" name="id" value="{$notice['id']}" />
        <div class="form-group">
            <label class="col-lg control-label">排序</label>
            <div class="col-sm-9 col-xs-12">
                {ife 'shop.notice' $notice}
                    <input type="text" name="displayorder" class="form-control" value="{$notice['displayorder']}" />
                {else}
                    <div class='form-control-static'>{$notice['displayorder']}</div>
                {/if}
            </div>
        </div>
        <div class="form-group">
            <label class="col-lg control-label must">公告标题</label>
            <div class="col-sm-9 col-xs-12">
                {ife 'shop.notice' $notice}
                    <input type="text" id='title' name="title" class="form-control" value="{$notice['title']}" data-rule-required='true' />
                {else}
                    <div class='form-control-static'>{$notice['title']}</div>
                {/if}
            </div>
        </div>
        <div class="form-group">
            <label class="col-lg control-label">公告图片</label>
            <div class="col-sm-9 col-xs-12">
                {ife 'shop.notice' $notice}
                    {php echo tpl_form_field_image2('thumb', $notice['thumb'])}
                    <span class="help-block">正方型图片</span>
                {else}
                    {if !empty($notice['thumb'])}
                        <a href='{php echo tomedia($notice['thumb'])}' target='_blank'>
                        <img src="{php echo tomedia($notice['thumb'])}" style='width:100px;border:1px solid #ccc;padding:1px' />
                    {/if}
                {/if}
            </div>
        </div>
        <div class="form-group">
            <label class="col-lg control-label">公告链接</label>
            <div class="col-sm-9 col-xs-12">
                {ife 'shop.notice' $notice}
                    <div class="input-group form-group" style="margin: 0;">
                        <input type="text" name="link" class="form-control" value="{$notice['link']}" id="noticelink" />
                        <span class="input-group-btn">
                            <span data-input="#noticelink" data-toggle="selectUrl" class="btn btn-default">选择链接</span>
                        </span>
                    </div>
                    <span class="help-block">如果输入链接，则不显示内容，直接跳转</span>
                {else}
                    <div class='form-control-static'>{$notice['link']}</div>
                {/if}
            </div>
        </div>
        <div class="form-group">
            <label class="col-lg control-label">公告内容</label>
            <div class="col-sm-9 col-xs-12">
                {ife 'shop.notice' $notice}
                    {php echo tpl_ueditor('detail',$notice['detail'])}
                {else}
                    <textarea id='detail' style='display:none'>{$notice['detail']}</textarea>
                    <a href='javascript:preview_html("#detail")' class="btn btn-default">查看内容</a>
                {/if}
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg control-label">是否显示</label>
            <div class="col-sm-9 col-xs-12">
                {ife 'shop.notice' $notice}
                    <label class='radio-inline'>
                        <input type='radio' name='status' value=1' {if $notice['status']==1}checked{/if} /> 是
                    </label>
                    <label class='radio-inline'>
                        <input type='radio' name='status' value=0' {if $notice['status']==0}checked{/if} /> 否
                    </label>
                {else}
                    <div class='form-control-static'>{if empty($notice['status'])}否{else}是{/if}</div>
                {/if}
            </div>
        </div>
        <div class="form-group"></div>
        <div class="form-group">
            <label class="col-lg control-label"></label>
            <div class="col-sm-9 col-xs-12">
                {ife 'shop.notice' $notice}
                    <input type="submit"  value="提交" class="btn btn-primary"  />
                {/if}
                <input type="button" name="back" onclick='history.back()' {ifp 'shop.notice.add|shop.notice.edit'}style='margin-left:10px;'{/if} value="返回列表" class="btn btn-default" />
            </div>
        </div>
    </form>
</div>

{template '_footer'}